<template>
    <div class="assignCustomers">
      <h2 class="title">{{buildingAlias}}</h2>
       <div class="adviserChoose">
          <Select
            v-model="adviserVal"
            placeholder="选择需分出客户的人员"
            @on-change="adviserChange"
            style="width: 220px;margin-top:10px;"
          >
            <Option
              v-for="(item, index) in adviserList"
              :key="index"
              :value="item.userId"
              :label="item.userName"
            >
            </Option>
            </Option>
          </Select>
        </div>
        <div class="btn"><span>共{{customerAllLength}}客户</span> <Button type="primary" style="width:80px;" @click="modalOut(1)">全部分出</Button>    </div>
        <div class="btn"><span>已选{{customerChoosedLength}}客户</span> <Button type="primary" style="width:80px;" @click="modalOut(0)">分出</Button>    </div>

        <div class="tab">
          <Table
            :loading="loading"
            @on-selection-change="tableChange"
            ref="TableHeight"
            :max-height="onresizeHeight"
            :columns="columns"
            :data="data"
            border
          >
          </Table>
        </div>

      <!-- 分页 -->
      <div class="pagePublicStyle" v-show="pageData.total > 0">
        <div class="totalCount">
          当前第 {{ pageData.page }} 页， 当前第
          {{ (pageData.page - 1) * pageData.rows + 1 }} 条到第
          {{
            pageData.page * pageData.rows > pageData.total
              ? pageData.total
              : pageData.page * pageData.rows
          }}
          条， 共 {{ pageData.total }} 条
        </div>
        <Page
          :total="pageData.total"
          :page="pageData.page"
          :page-size-opts="pageData.pageSizeOpts"
          :page-size = pageData.rows
          @on-change="pageOnChangeFun"
          @on-page-size-change="pageOnPageSizeChangeFun"
          show-elevator
          show-sizer
          show-total
        />
      </div>


      <!-- table 头部筛选 -->
      <table_filter :options="options" :channelType="true" :channelList="sourceChannelList"   @cancelFilterFun="cancelFilterFun" @okFilterFun="okFilterFun"></table_filter>

        <Modal
          v-model="modal1"
          title="请选择需分入客户的人员"
          :footer-hide="true"
          @on-cancel="modalCancel">
            <div class="tab">
              <Table
                @on-select="tableChange1"
                :columns="columns1"
                :data="data1"
                border
                height="400"
              >
              </Table>
            </div>

            <div class="transferFooter">
              <Button @click="modalCancel">取消</Button>
              <Button type="info" @click="modalOk">确定</Button>
            </div>
        </Modal>
  </div>
</template>
<script>
import {
  adviserList,
  aggChannelQueryGroupBuilding,
  getCustomerList1,
  customerinfoHeadList,
  customerAssignment,
  getCustomerListNew,
  customerHeadList
} from "@/api/customerManagement.js";
import { getCaseList } from "@/api/homeApi.js";
import table_filter from "@/components/table_filter";
import Helper from "@/common/helper.js";
import tool from "@/common/tool";
export default {
  components: { table_filter },
  data() {
    return {
      adviserVal: this.$route.query.userId ? this.$route.query.userId : "",
      adviserList: "",
      buildingId: this.$route.query.buildingId
        ? this.$route.query.buildingId
        : JSON.parse(this.$tool.getStorage("caseBuildingId")),

      buildingAlias: "",
      cityCode: "",

      loading: false,
      // adviserId: "", //顾问id
      customerChoosedLength: 0,
      customerAllLength: 0,
      modal1: false,
      currentChoose: "",
      currentChooseName:'',
      operationType: 0, //分出类型
      customerIds: [], //选中的客户ID

      columns: [
        {
          type: "selection",
          title: "选择",
        },
        {
          title: '客户姓名',
          key: 'customer_name',
          minWidth: 130,
          render: (h, params) => {
            return h('div',  params.row.customerName || '-');
          },
          renderHeader: (h, params) => {
            return h('div',[
              h('span', {}, '客户姓名'),
              h('Icon', {
                props: {
                  type: 'ios-arrow-down',
                  size: '16'
                },
                style: {
                  marginLeft: '5px'
                },
                nativeOn: {
                  'mouseover': (event) => {
                    event.stopPropagation();
                    this.thMouseoverFun(event, 'input-customerName', '请输入客户姓名', 218);
                  },
                  'mouseleave': (event) => {
                    event.stopPropagation();
                    this.thMouseoutFun();
                  }
                }
              })
            ])
          }
        },
        {
          title: '手机号码',
          key: 'customer_phone',
          minWidth: 130,
          render: (h, params) => {
            return h('div',  this.$options.filters.mobilePhoneNumberFourAsterisk(params.row.customerPhone) || '-');
          },
          renderHeader: (h, params) => {
            return h('div',[
              h('span', {}, '手机号码'),
              h('Icon', {
                props: {
                  type: 'ios-arrow-down',
                  size: '16'
                },
                style: {
                  marginLeft: '5px'
                },
                nativeOn: {
                  'mouseover': (event) => {
                    event.stopPropagation();
                    this.thMouseoverFun(event, 'input-phoneNumber-11', '请输入手机号码', 260);
                  },
                  'mouseleave': (event) => {
                    event.stopPropagation();
                    this.thMouseoutFun();
                  }
                }
              })
            ])
          }
        },
        {
          title: '来源渠道',
          key: 'channel_source',
          minWidth: 120,
          render: (h, params) => {
            return h('div', params.row.channelSource || '-');
          },
          renderHeader: (h, params) => {
            return h('div',[
              h('span', {}, '来源渠道'),
              h('Icon', {
                props: {
                  type: 'ios-arrow-down',
                  size: '16'
                },
                style: {
                  marginLeft: '5px'
                },
                nativeOn: {
                  'mouseover': (event) => {
                    event.stopPropagation();
                    this.thMouseoverFun(event, 'SelectChannel-sourceChannelVal-aa-multiple', '请选择来源渠道', 200);
                  },
                  'mouseleave': (event) => {
                    event.stopPropagation();
                    this.thMouseoutFun();
                  }
                }
              })
            ])
          }
        },
        {
          title: '意向等级',
          key: 'intention_level',
          minWidth: 120,
          render: (h, params) => {
            return h('div',  params.row.intentionLevel || '-' );
          },
          renderHeader: (h, params) => {
            return h('div',[
              h('span', {}, '意向等级'),
              h('Icon', {
                props: {
                  type: 'ios-arrow-down',
                  size: '16'
                },
                style: {
                  marginLeft: '5px'
                },
                nativeOn: {
                  'mouseover': (event) => {
                    event.stopPropagation();
                    this.thMouseoverFun(event, 'Select-customerLevelVal-customerLevelList-multiple', '请选择意向等级', 200);
                  },
                  'mouseleave': (event) => {
                    event.stopPropagation();
                    this.thMouseoutFun();
                  }
                }
              })
            ])
          }
        },
        {
          title: '客户进度',
          key: 'status',
          minWidth: 120,
          render: (h, params) => {
            return h('div', (params.row.status || '-'));
          },
          renderHeader: (h, params) => {
            return h('div',[
              h('span', {}, '客户进度'),
              h('Icon', {
                props: {
                  type: 'ios-arrow-down',
                  size: '16'
                },
                style: {
                  marginLeft: '5px'
                },
                nativeOn: {
                  'mouseover': (event) => {
                    event.stopPropagation();
                    this.thMouseoverFun(event, 'Select-customerProgressVal-customerProgressList-multiple', '请选择客户进度', 200);
                  },
                  'mouseleave': (event) => {
                    event.stopPropagation();
                    this.thMouseoutFun();
                }
              }
            })
          ])
        }
        },
        {
          title: '创建日期',
          key: 'create_time',
          minWidth: 160,
          render: (h, params) => {
            return h('div',params.row.createTime&&params.row.createTime!='-'?this.$tool.dateFtt('yyyy/MM/dd hh:mm',params.row.createTime):'-');
          },
          renderHeader: (h, params) => {
            return h('div',[
              h('span', {}, '创建日期'),
              h('Icon', {
                props: {
                  type: 'ios-arrow-down',
                  size: '16'
                },
                style: {
                  marginLeft: '5px'
                },
                nativeOn: {
                  'mouseover': (event) => {
                    event.stopPropagation();
                    this.thMouseoverFun(event, "datePicker-createTimeVal-daterange", '请选择创建日期', 200);
                    
                  },
                  'mouseleave': (event) => {
                    event.stopPropagation();
                    this.thMouseoutFun();
                  }
                }
              })
            ])
          }
        },
      ],




      sourceChannelList:[],//渠道列表
      
      options: {
        type: '',   // form类型  Input / DatePicker / Checkbox / Select / 操作配置头部
        nameCrimeSceneName: '',
        nameCrimeSceneVal: '',
        placeholder: '',  // 提示语
        left: -1000,    // 弹框fixed => left
        iconLeft: 0,  // 弹框icon => left
        top: -1000,    // 弹框fixed => top
        width: 218,   // 弹框fixed => top
        setTimeout: null,    // 鼠标离开三角形 200毫秒 关闭弹框



        customerName: '',  // 客户姓名 字段
        phoneNumber: '', // 电话 字段



        sourceChannelVal: '',//来源渠道
        // sourceChannelList:[],

        customerProgressVal: '',//客户进度字段
        customerProgressList:[],//客户进度筛选数据
        
        customerLevelVal:'', // 客户等级 字段
        customerLevelList: [], //客户等级 数据

        intentionPurposeVal:'',//置业目的
        intentionPurposeList:[],

        intentionProductVal:'',//意向业态
        intentionProductList:[],

        intentionAreaVal:'',//意向面积
        intentionAreaList:[],

        intentionTotalPriceVal:'',//意向总价
        intentionTotalPriceList:[],

        intentionAveragePriceval:'',//意向单价
        intentionAveragePriceList:[],

        intentionHouseTypeVal:'',//意向户型
        intentionHouseTypeList:[],

        areaVal: '',  // 意向区域
        areaList: [],  

        sourceTypeVal:'',//创建方式
        sourceTypeList:[{name:'扫码授权',val:1},{name:'手动录入',val:2},{name:'网络来客',val:3}],

        checkInMethodVal:'',//签到方式
        checkInMethodList:[{name:'扫码签到',val:1},{name:'手动签到',val:2},{name:'新增签到',val:3},],

        createTimeVal:'',//创建时间

        lastVisitTimeVal:'',//最近到访时间

        lastFollowUpTimeVal:'',//最近跟进时间

        attributionConsultantVal:'',//归属顾问
        attributionConsultantList:[],
      },

      data: [],

      columns1: [
        {
          title: "选择",
          key: "userId",
          width: 70,
          align: "center",
          // render:(h, params) =>{
          //       return h('div',params.row._index-0+1)
          //     },
          render: (h, params) => {
            let id = params.row.userId;
            let flag = false;
            if (this.currentChoose === id) {
              flag = true;
            } else {
              flag = false;
            }
            let self = this;
            return h("div", [
              h("Radio", {
                props: {
                  value: flag,
                },
                on: {
                  "on-change": () => {
                    console.log(params.row,'params.row');
                    this.currentChooseName = params.row.userName
                    console.log(id);
                    self.currentChoose = id;
                  },
                },
              }),
            ]);
          },
        },
        {
          title: "姓名",
          key: "userName",
          minWidth: 120,
        },
        {
          title: "手机号",
          key: "phone",
          minWidth: 120,
        },
      ],

      data1: [],
      pageData: {
        total: 0,
        page: 1,
        rows: 50,
        pageSizeOpts: [50, 40, 30, 20, 10],
      },
      onresizeHeight: 0, //tabl高

      // 筛选
      // sourceChannelList: [], //渠道列表
      // options: {
      //   type: "", // form类型  Input / DatePicker / Checkbox / Select / 操作配置头部
      //   nameCrimeSceneName: "",
      //   nameCrimeSceneVal: "",
      //   placeholder: "", // 提示语
      //   left: -1000, // 弹框fixed => left
      //   iconLeft: 0, // 弹框icon => left
      //   top: -1000, // 弹框fixed => top
      //   width: 218, // 弹框fixed => top
      //   setTimeout: null, // 鼠标离开三角形 200毫秒 关闭弹框
      //   customerName: "", // 客户姓名 字段
      //   phoneNumber: "", // 电话 字段
      //   areaVal: "", // 地区 字段
      //   areaList: [], // 地区 字段
      //   sourceVal: [], // 来源 字段
      //   sourceList: [
      //     { name: "香蕉", val: "11" },
      //     { name: "苹果", val: "22" },
      //   ], // 来源 数据
      //   customerLevelVal: "", // 客户等级 字段
      //   customerLevelList: [], // 客户等级 数据
      //   // customerLevelList:this.appId == 36? []: [
      //   //         { name: "请选择", val: "-1" },
      //   //         { name: "A", val: "1" },
      //   //         { name: "B", val: "2" },
      //   //         { name: "C", val: "3" },
      //   //         { name: "D", val: "4" },
      //   //       ], // 客户等级 数据
      //   creationTimeVal: "", // 创建时间 字段
      //   autoCompleteVal: "", // 服务人员 字段
      //   daterange: "", // 年月日
      //   datetimerange: "", // 年月日时分秒
      //   multipleCheckbox: [], // Checkbox 字段
      //   checkboxList: [
      //     { name: "香蕉", val: "11" },
      //     { name: "苹果", val: "22" },
      //   ], // Checkbox数据
      //   selectVal: [], // Select 多项 字段
      //   selectList: [
      //     { name: "香蕉", val: "11" },
      //     { name: "苹果", val: "22" },
      //   ], // select数据
      //   operatingVal: [], // 操作 字段
      //   tableTitleList: [], // 操作 数据
      //   customerProgressVal: "",
      //   // customerProgressList: [
      //   //         { name: "请选择", val: "-1" },
      //   //         { name: "预约", val: "1" },
      //   //         { name: "首访", val: "2" },
      //   //         { name: "回笼", val: "3" },
      //   //         { name: "验资", val: "4" },
      //   //         { name: "认筹", val: "5" },
      //   //         { name: "意向金", val: "6" },
      //   //         { name: "认购", val: "7" },
      //   //         { name: "签约", val: "8" },
      //   //         { name: "付款", val: "9" },
      //   //         { name: "交房;B+", val: "10" },
      //   //         { name: "互动", val: "11" },
      //   //         { name: "留资", val: "12" },
      //   //         { name: "到访", val: "13" },
      //   //         { name: "认购", val: "14" },
      //   //         { name: "签约", val: "15" },
      //   //         { name: "退购", val: "16" },
      //   //         { name: "退签", val: "17" },
      //   //       ],
      //   customerProgressList: [
      //     // { name: "请选择", val: "-1" },
      //     // { name: "未到访", val: "1" },
      //     // { name: "首访", val: "2" },
      //     // { name: "回笼", val: "3" },
      //     // // { name: "验资", val: "4" },
      //     // // { name: "认筹", val: "5" },
      //     // // { name: "意向金", val: "6" },
      //     // { name: "认购", val: "7" },
      //     // { name: "签约", val: "8" },
      //     // { name: "回款", val: "9" },
      //     // { name: "交房", val: "10" },
      //     // { name: "互动", val: "11" },
      //     // { name: "留资", val: "12" },
      //     // { name: "到访", val: "13" },
      //     // { name: "认购", val: "14" },
      //     // { name: "签约", val: "15" },
      //     // { name: "退购", val: "16" },
      //     // { name: "退签", val: "17" },
      //   ],

      //   sourceChannelVal: "",
      //   sourceChannelList: this.$tool.getStorage("appId") == 36 ? [] : "",
      //   interactiveWayVal: "",
      //   dateInteractionVal: "",
      //   retentionDateVal: "",
      //   dateVisitVal: "",
      //   buildingName: "",
      //   channelName: "",
      //   visitStatusList: [
      //     { name: "请选择", val: "-1" },
      //     { name: "待完成", val: "1" },
      //     { name: "标记完成", val: "2" },
      //     { name: "已失效", val: "3" },
      //     { name: "已过期", val: "4" },
      //     { name: "超时到访", val: "5" },
      //   ],
      //   visitStatus: "",
      //   servicePersonnel: "",
      // },
    };
  },
  methods: {
    modalOut(val) {
      if (!this.adviserVal) {
        this.$Message.warning("请选择被分配人员。");
        return false;
      }
      if (val == 0) {
        this.operationType = 0;
        console.log(this.customerIds.length, "this.customerIds.length");
        if (this.customerIds.length) {
          this.modal1 = true;
          this.getAdviserList1();
        } else {
          this.$Message.warning("请选择分配的客户。");
        }
      } else {
        if (this.data.length) {
          this.operationType = 1;
          this.modal1 = true;
          this.getAdviserList1();
        } else {
          this.$Message.warning("该人员还没有客户。");
        }
      }

      // if(this.customerIds.length){
      //   this.modal1 = true;
      //   this.getAdviserList1()
      // }else{
      //   this.$Message.warning('请选择分配的客户。');
      // }
    },
    // 分配确定
    modalOk() {
      if (!this.currentChoose) {
        this.$Message.warning("请选择分给的人员。");
        return false;
      }
      let lastName='';
      this.adviserList.forEach(item => {
        if(item.userId==this.adviserVal){
          lastName = item.userName
        }
      });
      // console.log(this.operationType,this.customerChoosedLength,this.customerAllLength);

      let numLen= this.operationType?this.customerAllLength:this.customerChoosedLength
      this.$Modal.confirm({
        title: '分配客户确认',
        content: `<p>是否将${lastName}的${numLen}个客户分配给${this.currentChooseName}？</p>`,
        onOk: () => {
          let params = {
            userId: Number(JSON.parse(tool.getStorage("userMess")).userId),
            buildingId: this.buildingId,
            newUserId: this.currentChoose,
            oldUserId: this.adviserVal,
            operationType: this.operationType, //操作类型：0部分，1全部
            // customerIds: this.customerIds, //部分分配客户的ids
          };
          if (this.operationType == 0) {
            params.customerIds = this.customerIds;
          }
          customerAssignment(params)
            .then((res) => {
              console.log("分配是否成功", res);
              this.modal1 = false;
              this.currentChoose = "";
              this.customerIds = [];
              this.customerChoosedLength = 0;
              this.$Message.success("分配成功。");
              this.reCustomerList();
              // this.adviserList = res;
              // this.data1 = res;
            })
            .catch((err) => {
              this.$Message.error(err);
            });
        },
        onCancel: () => {
            this.$Message.info('Clicked cancel');
        }
      });

      
    },
    modalCancel() {
      this.currentChoose = "";
      this.modal1=false;
    },
    tableChange1(val) {
      console.log(val, "val");
    },
    //顾问更改
    adviserChange(val) {
      if (val) {
        // this.adviserId = val;
        console.log(
          this.adviserVal,
          this.adviserVal,
          "tttttttttttttttttttttttt"
        );
        this.pageData.page = 1;
        console.log(this.data1, "11111111111");
        console.log(this.adviserList, "22222222222");
        this.reCaseList().then(() => {
          //获取案场列表
          this.customerinfoHeadListData();
          this.reCustomerList();
          this.aggChannelQueryGroupList();
        });
      }
    },

    //案场列表
    reCaseList() {
      return new Promise((resolve, reject) => {
        let params = {
          userId: this.adviserVal,
        };
        getCaseList(params)
          .then((res) => {
            console.log("案场列表", res);
            res.list.forEach((item) => {
              if (item.buildingId == this.buildingId) {
                this.buildingAlias = item.buildingAlias;
                this.cityCode = item.cityCode;
              }
            });
            resolve();
          })
          .catch((err) => {
            this.$Message.error(err);
          });
      });
    },

    //表格选中
    tableChange(val) {
      this.customerIds = [];
      console.log(val,this.customerIds, "我是选中的");
      if (val && val.length) {
        this.customerChoosedLength = val.length;
        val.forEach((item) => {
          if (item.customerId) {
            this.customerIds.push(Number(item.customerId));
          }
        });
        console.log(val,this.customerIds, "我是选中的111");
      } else {
        this.customerIds = [];
      }
    },

    //根据案场查询所有顾问
    getAdviserList() {
      let params = {
        buildingId: Number(this.buildingId),
      };
      adviserList(params)
        .then((res) => {
          console.log("根据案场查询所有顾问", res);
          this.adviserList = res;
        })
        .catch((err) => {
          this.$Message.error(err);
        });
    },
    getAdviserList1() {
      let params = {
        buildingId: Number(this.buildingId),
      };
      adviserList(params)
        .then((res) => {
          console.log("根据案场查询所有顾问111111111", res);
          this.data1 = res;
          let _index = this.data1.findIndex((item) => {
            return item.userId == this.adviserVal;
          });
          this.data1.splice(_index, 1);
        })
        .catch((err) => {
          this.$Message.error(err);
        });
    },

    //获取渠道列表
    aggChannelQueryGroupList() {
      aggChannelQueryGroupBuilding({
        cityCode: this.cityCode,
        page: 1,
        rows: 100,
        buildingId: this.buildingId,
      })
        .then((res) => {
          console.log("来源渠道列表", JSON.parse(JSON.stringify(res)));
         if (res&&res.list&&res.list.length > 0) {
            this.sourceChannelList = res.list
            console.log('我是来源渠道啊',this.sourceChannelList);
          } else {
            this.sourceChannelList = []
          }
        })
        .catch((err) => {
          console.log("渠道配置列表报错", err);
        });
    },

    reCustomerList() {
      this.customerChoosedLength=0;
      this.customerAllLength=0;
      // console.log(this.adviserId, "this.adviserId");
      this.loading = true;
      //客户列表
      // let params = {
      //   buildingId: Number(this.buildingId),
      //   operateType: 1,
      //   userId: this.adviserVal, //顾问id
      //   page: this.pageData.page,
      //   rows: this.pageData.rows,
      //   ifSubordinate: 2, //是否筛选下属客户

      //   channelSource: this.options.sourceChannelVal, //来源渠道
      //   customerName: this.options.customerName, //客户姓名
      //   phone: this.options.phoneNumber, //手机号
      //   intentionLevel:
      //     this.options.intentionLevel == -1
      //       ? ""
      //       : this.options.customerLevelVal, //意向等级
      //   status:
      //     this.options.customerProgressVal == -1
      //       ? ""
      //       : this.options.customerProgressVal, //客户进度

      //   startTime: "", //创建时间
      //   endTime: "", //创建时间

      //   startTime:
      //     (this.options.creationTimeVal &&
      //       this.options.creationTimeVal[0] &&
      //       Helper.timestampToTime(this.options.creationTimeVal[0])) ||
      //     "",
      //   endTime:
      //     (this.options.creationTimeVal &&
      //       this.options.creationTimeVal[1] &&
      //       Helper.timestampToTime(this.options.creationTimeVal[1])) ||
      //     "",
      // };
      let params = {
        page: this.pageData.page,
        rows: this.pageData.rows,
        buildingId:Number(this.buildingId),//楼盘id
        userIds: this.adviserVal?[this.adviserVal]:[],//归属id
        customerName: this.options.customerName, //客户名字
        customerPhone: this.options.phoneNumber, //手机号
        // userCustomerId:JSON.parse(this.$tool.getStorage("customerListFormStatistics"))||[],//首页统计面板过来, //用户客户ID

        status:this.options.customerProgressVal||[],//客户进度
        channelSource:this.options.sourceChannelVal||[],//来源渠道
        intentionLevel:this.options.customerLevelVal||[],//意向等级

        customerCreateStartTime:this.options.createTimeVal && this.options.createTimeVal[0] && Helper.timestampToTime(this.options.createTimeVal[0],'date')+" 00:00:00" || "",//创建开始时间
        customerCreateEndTime:this.options.createTimeVal && this.options.createTimeVal[1] && Helper.timestampToTime(this.options.createTimeVal[1],'date')+" 23:59:59" || "",

        // intentionPurpose:this.options.intentionPurposeVal||[],//置业目的
        // intentionProduct:this.options.intentionProductVal||[],//意向业态
        // intentionHouseType:this.options.intentionHouseTypeVal||[],//意向户型
        // checkInMethod:this.options.checkInMethodVal||[],//签到方式            
        // createMethod:this.options.sourceTypeVal||[],//	创建方式
        // intentionRegion:this.options.areaVal||[],//意向区域
        // intentionTotalPrice:this.options.intentionTotalPriceVal||[],//意向总价
        // intentionArea:this.options.intentionAreaVal||[],//意向面积
        // intentionAveragePrice:this.options.intentionAveragePriceVal||[],//意向单价       
        
        // customerName:'',//客户姓名(支持模糊查询)
        // ustomerPhone:'',//客户手机号(最少输入四位,同时搜索主号码和备用号码)
        
        
        //创建结束时间
        // lastFollowUpStartTime:this.options.lastVisitTimeVal && this.options.lastVisitTimeVal[0] && Helper.timestampToTime(this.options.lastVisitTimeVal[0],'date')+" 00:00:00" || "",//最近跟进开始时间lastVisitTimeVal
        // lastFollowUpEndTime:this.options.lastVisitTimeVal && this.options.lastVisitTimeVal[0] && Helper.timestampToTime(this.options.lastVisitTimeVal[1],'date')+" 23:59:59" || "",//最近跟进结束时间
        // lastVisitStartTime:this.options.lastFollowUpTimeVal && this.options.lastFollowUpTimeVal[0] && Helper.timestampToTime(this.options.lastFollowUpTimeVal[0],'date')+" 00:00:00" || "",//最近到访开始时间lastFollowUpTimeVal
        // lastVisitEndTime:this.options.lastFollowUpTimeVal && this.options.lastFollowUpTimeVal[0] && Helper.timestampToTime(this.options.lastFollowUpTimeVal[1],'date')+" 23:59:59" || "",//最近到访结束时间

        //  sidx:"",//排序字段
        //  sord:'',//排序类型,asc:从小到大,desc:从大到小


      }
      console.log(params,'分配客户的列表参数');
      getCustomerListNew(params)
        .then((res) => {
          console.log("获取客户列表", res);
          this.loading = false;
          if (res && res.records) {
            this.data = res.records;
            this.pageData.total = Number(res.total);
            this.customerAllLength = Number(res.total);
            this.$nextTick(() => {
              this.onresizeHeight =
                window.innerHeight - this.$refs.TableHeight.$el.offsetTop - 100;
            });
          } else {
            console.log("没有值");
            this.pageData.total = 0;
            this.customerAllLength = 0;
            this.data = [];
          }
        })
        .catch((err) => {
          this.loading = false;
          this.$Message.error(err);
        });
    },

    // table from 取消事件
    cancelFilterFun(options) {
      this.reCustomerList();
    },
    // table from 确定事件
    okFilterFun(options) {
      console.log(options, "我是确定的options");
      this.reCustomerList();
      // console.log(this.options)
      // //return;
      // if (this.appId == 36) {
      //   console.log("刷新表头···············");
      //   if(this.$tool.getStorage("customerListFormStatistics")){
      //     this.initData()
      //   }else{
      //     this.initData()
      //     this.customerinfoHeadListData()
      //   }
      // } else {
      //   this.initData()
      // }
    },

    // table 鼠标移到三角形事件
    thMouseoverFun(event, type, placeholder, width) {
      this.options.type = type;
      this.options.placeholder = placeholder;
      this.options.left =
        event.currentTarget.getBoundingClientRect().left - (width / 2 - 5) <=
        200
          ? 200
          : event.currentTarget.getBoundingClientRect().left -
              (width / 2 - 5) +
              width >
            document.documentElement.clientWidth
          ? document.documentElement.clientWidth - width
          : event.currentTarget.getBoundingClientRect().left - (width / 2 - 5);
      this.options.iconLeft = event.currentTarget.getBoundingClientRect().left;
      this.options.top = event.currentTarget.getBoundingClientRect().top + 24;
      this.options.width = width;
    },
    // table 鼠标离开三角形事件
    thMouseoutFun() {
      this.options.setTimeout = setTimeout(() => {
        this.options.left = -1000;
        this.options.top = -1000;
      }, 100);
    },

    // 分页 页码改变事件
    pageOnChangeFun(page) {
      this.customerIds = [];
      this.pageData.page = page;
      this.reCustomerList();
    },
    // 分页 每页条数改变事件
    pageOnPageSizeChangeFun(page) {
      this.customerIds = [];
      this.pageData.rows = page;
      this.reCustomerList();
    },

    // 初始化获取数据
    initTableHeight() {
      this.$nextTick(() => {
        this.onresizeHeight =
          window.innerHeight - this.$refs.TableHeight.$el.offsetTop - 60;
      });
    },
    customerinfoHeadListData() {
      customerHeadList({
         buildingId: this.buildingId,
         appId:Number(JSON.parse(tool.getStorage('userMess')).appId) 
        })
        .then((res) => {
          console.log("获取头部信息", res);
          let arrData = res.hiedHead.concat(res.showHead);
          if (arrData) {
            arrData.forEach((item) => {
              //客户进度
              if(item.dbKey == 'status' && item.options && item.options.length>0){
                this.options.customerProgressList = item.options.map(option=>{
                  return{
                    name:option.optionValue,
                    val:option.optionId+""
                  }
                })                  
              }
              //意向等级
              if(item.dbKey == "intention_level" && item.options && item.options.length>0){
                this.options.customerLevelList = item.options.map(option=>{
                  return{
                    name:option.optionValue,
                    val:option.optionId+""
                  }
                })                  
              }
            });
          }
        })
        .catch((err) => {
          this.$Message.error(err);
        });
    },
  },
  computed: {},
  created() {
    this.getAdviserList();
    if (this.adviserVal) {
      this.reCaseList().then(() => {
        //获取案场列表
        this.customerinfoHeadListData();
        this.reCustomerList();
        this.aggChannelQueryGroupList();
      });
    }
  },
  mounted() {
    window.onresize = () => {
      return (() => {
        setTimeout(() => {
          this.onresizeHeight =
            window.innerHeight - this.$refs.TableHeight.$el.offsetTop - 60;
        }, 10);
      })();
    };
  },
  watch: {},
};
</script>
<style lang="scss" scoped>
.assignCustomers {
  padding: 20px;
  .btn {
    margin-top: 5px;
    width: 200px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    line-height: 32px;
  }
  .tab {
    margin-top: 20px;
  }
  .pagePublicStyle {
    // text-align: right;
    padding: 14px 10px;
    // margin-right: 30px;
    display: flex;
    justify-content: space-between;
    flex-direction: row;
  }
  
}
.transferFooter {
    margin-top: 20px;
    text-align: center;
    button {
      width: 80px;
      margin: 0 10px;
    }
  }
</style>
